package com.ficus.road.maintain.controller;

import com.ficus.road.maintain.client.Response.ManagementUnitDetailResponse;
import com.ficus.road.maintain.client.Response.ManagementUnitResponse;
import com.ficus.road.maintain.core.model.UnitDensityResponse;
import com.ficus.road.maintain.core.model.zh.UnitScoreItem;
import com.ficus.road.maintain.service.XljVideoService;
import com.ficus.road.maintain.dao.UnitScoreDetailDao;
import com.ficus.road.maintain.service.CompanyService;
import com.ficus.road.maintain.service.UnitService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xiawen yang
 * @date 2022/8/20 下午4:52
 */
@RestController
@RequiredArgsConstructor
@Slf4j
public class UnitController {
    private final CompanyService companyService;
    private final UnitService unitService;
    private final UnitScoreDetailDao unitScoreDetailDao;

    @Autowired
    XljVideoService xljVideoService;
    /**
     * 获取标段的病害密度
     *
     * @return
     */
    @GetMapping("/unit/disease/density")
    public ResponseEntity<List<UnitDensityResponse>> getRoadDensity() {
        List<UnitDensityResponse> unitDensity = companyService.getUnitDensity();
        return new ResponseEntity<>(unitDensity, HttpStatus.OK);
    }

    /**
     * 获取标段得分详情
     *
     * @return
     */
    @GetMapping("/unit/score/{unitId}")
    public ResponseEntity<List<UnitScoreItem>> getUnitScoreDetail(@PathVariable("unitId") String unitId) {
        return new ResponseEntity<>(unitService.getUnitScoreDetail(unitId), HttpStatus.OK);
    }

    /**
     *
     * @param unid
     * @return
     */
    @GetMapping("/unit/score1/{unitId}")
    public List<ManagementUnitDetailResponse> getManagementUnitDetail(@PathVariable("unitId") String unid) {
        return xljVideoService.getManagementUnitDetail(unid);
    }
    /**
     * 标段得分排行
     *
     * @return
     */
    @GetMapping("/unit/score/all")
    public ResponseEntity<ManagementUnitResponse> getUnitScoreRank() {
        return new ResponseEntity<>(unitService.getUnitScoreRank(), HttpStatus.OK);
    }
}
